import 'dart:convert';

import 'package:flutter_test/flutter_test.dart';
import 'package:timezone/data/latest.dart' as tz;

import 'package:flutter_utils_plus/flutter_utils_plus.dart';

import 'test_moment.dart';
import 'test_number.dart';
import 'test_string.dart';
import 'test_validate.dart';

void main() {
  tz.initializeTimeZones();
  // test('String', testString);
  // test('Moment', testMoment);
  // test('Number', testNumber);
  // test('Validate', testValidate);

  Function fn = debounce(() {
    print('1111');
  });
  fn();
  fn();
  fn();
  Function fn2 = throttle(() {
    print('2222');
  });
  fn2();
  fn2();
  Future.delayed(Duration(seconds: 2), () {
    fn2();
  });

  List list = [
    {'userId': 1, 'username': 'root'},
    {'userId': 2, 'username': 'admin', 'parentId': 1},
    {'userId': 3, 'username': 'user', 'parentId': 2}
  ];
  List result = arrayToTree(list, 'userId');
  print(jsonEncode(result));
  List result2 = treeToArray(result);
  print(jsonEncode(result2));
}
